﻿#include <iostream>
#include "ThreadPool.h"
#include <Windows.h>
mutex g_mutex;

// 任务函数
void Print(int num) {
    g_mutex.lock();
    cout << "线程id:" << this_thread::get_id() << "->" << num << endl;
    Sleep(1000);
    g_mutex.unlock();
}

int main()
{
    // 创建线程池
    ThreadPool pool(4);
    
    // 提交线程任务
    for (int i = 0; i < 8; i++)
    {
        pool.Commit(Print, i);
    }

    return 0;
}
